package com.fr.report.web.ui;

import com.fr.base.StringUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.web.Repository;

public abstract class WriteAbleRepeatEditor extends DirectWriteEditor
{
  private boolean removeRepeat = true;
  private String waterMark;

  public void setWaterMark(String paramString)
  {
    this.waterMark = paramString;
  }

  public String getWaterMark()
  {
    return this.waterMark;
  }

  public boolean isRemoveRepeat()
  {
    return this.removeRepeat;
  }

  public void setRemoveRepeat(boolean paramBoolean)
  {
    this.removeRepeat = paramBoolean;
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    if (StringUtils.isNotBlank(getWaterMark()))
      localJSONObject.put("watermark", getWaterMark());
    if (isRemoveRepeat())
      localJSONObject.put("norepeat", true);
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isCharacters())
    {
      String str = paramXMLableReader.getTagName();
      if ("waterMark".equals(str))
        setWaterMark(paramXMLableReader.getContent());
      if ("noRepeat".equals(str))
        setRemoveRepeat(Boolean.valueOf(paramXMLableReader.getContent()).booleanValue());
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (StringUtils.isNotBlank(this.waterMark))
      paramXMLPrintWriter.startTAG("waterMark").textNode(this.waterMark).end();
    if (!(this.removeRepeat))
      paramXMLPrintWriter.startTAG("noRepeat").textNode(String.valueOf(this.removeRepeat)).end();
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof WriteAbleRepeatEditor) && (super.equals(paramObject)) && (ComparatorUtils.equals(this.waterMark, ((WriteAbleRepeatEditor)paramObject).waterMark)) && (this.removeRepeat == ((WriteAbleRepeatEditor)paramObject).removeRepeat));
  }
}